<?php
App::uses('AppModel', 'Model');
/**
 * Country Model
 *
 * @property Continent $Continent
 * @property Currency $Currency
 * @property TypesRegion $TypesRegion
 * @property MenuCategory $MenuCategory
 * @property Region $Region
 */
class Country extends AppModel {

/**
 * Display field
 *
 * @var string
 */
	public $displayField = 'name';

	//Changement du niveau de récursive pour aller chercher dans les associations sur 2 niveaux
	public $recursive = 2;

	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
	public $belongsTo = array(
		'Continent' => array(
			'className' => 'Continent',
			'foreignKey' => 'continent_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Currency' => array(
			'className' => 'Currency',
			'foreignKey' => 'currency_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'TypesRegion' => array(
			'className' => 'TypesRegion',
			'foreignKey' => 'types_region_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

/**
 * hasMany associations
 *
 * @var array
 */
	public $hasMany = array(
		'MenuCategory' => array(
			'className' => 'MenuCategory',
			'foreignKey' => 'country_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Region' => array(
			'className' => 'Region',
			'foreignKey' => 'country_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);

	public $validate = array(
		'name' => array(
			'isEmpty' => array(
				'rule' 			=> 'notEmpty', //or: array('rulename', 'param1', 'param 2') Exemple avec between 1 and 10
				'message' 		=> 'Your field shounldnt be empty'
			),
			'noNumber' => array(
				'rule' 		=> '/^[a-zA-Zéè]+$/i', //i pour isensitive: non sensible à la casse
				'message' 	=> 'Pas de nombre bouffon'
			),
		)		
	);	

}
